package com.example.d01线程的实现.testCallalbe;

import java.util.concurrent.*;

public class test implements Callable<Boolean> {

    @Override
    public Boolean call() throws Exception {
        for (int i = 0; i < 10; i++) {
            System.out.println("线程："+Thread.currentThread().getName());
        }
        return true;
    }

    public static void main(String[] args) {
        test t1=new test();
        test t2=new test();
        test t3=new test();

        //创建执行服务
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        //提交任务
        Future<Boolean> r1 = executorService.submit(t1);
        Future<Boolean> r2 = executorService.submit(t2);
        Future<Boolean> r3 = executorService.submit(t3);

        //关闭服务
        executorService.shutdownNow();
    }
}
